package com.nan.book;

public class Book {
    private String name;//定义名字
    private String author;//作者
    private int price;//价格
    private String type;//类型
    private boolean isBorrowed;//是否被借出，默认值本身为false
//当我们使用 private 来修饰字段的时候, 就无法直接使用这个字段了
//此时如果需要获取或者修改这个 private 属性, 就需要使用 getter / setter 方法.

//带有三个参数的构造方法
    public Book(String name, String author, int price, String type) {//构造方法
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }
//可以使用 toString 这样的方法来将对象自动转成字符串
//toString 方法会在 println 的时候被自动调用
//将对象转成字符串这样的操作我们称为 序列化
    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
                ", isBorrowed=" + isBorrowed +
                '}';
    }

}
